/**
* @Title: SampleController.java
* @Package com.an.spring_boot_learn
* @Description: TODO(用一句话描述该文件做什么)
* @author antch,861710865@qq.com
* @date 2017年7月9日 下午9:27:49
* @version V1.0
*/


package com.an.spring_boot_learn;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
* @ClassName: SampleController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author antch,861710865@qq.com
* @date 2017年7月9日 下午9:27:49
*
*/
@Controller
@SpringBootApplication
public class SampleController {

	private static Logger log = LoggerFactory.getLogger(SampleController.class);
	/*
	 * Spring boot读取配置文件中的值，不需要像spring MVC中那样麻烦
	 *
	 * 未能成功实现
	 */
	@Value("${server.port}")
	private  String serverPort;


	@Autowired
	private   SecurityBeanByProperties beanByProperties;

	public String getServerPort() {
		return serverPort;
	}

	@RequestMapping("/home")
	@ResponseBody
	public String home() {
		log.info("info 级别的日志");
		System.out.println("hello spring boot");

		return "Hello ,Spring boot" + beanByProperties.toString();
	}

	/**
	* @Title: main
	* @Description: TODO(启动spring boot)
	* @param @param args    设定文件
	* @return void    返回类型
	* @throws
	*/

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		System.out.println("*******" + new SampleController().getServerPort() + "*******");
		/*
		 * 关闭banner
		 *Spring Boot ::        (v1.4.1.RELEASE)
		 *需要使用app.setBannerMode(Banner.Mode.OFF);来关闭banner
		 */
		SpringApplication app = new SpringApplication(SampleController.class);
		//app.setBannerMode(Banner.Mode.OFF);
		app.run(args);

		//SpringApplication.run(SampleController.class, args);

	}

}
